package com.example.administrator.zhongyichou.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.example.administrator.zhongyichou.Bean.BaseEventBean;
import com.example.administrator.zhongyichou.R;
import com.example.administrator.zhongyichou.adapter.MillionsHelpExpandableAdapter;
import com.example.administrator.zhongyichou.base.BaseActivity;
import com.example.administrator.zhongyichou.help.CallPhone;
import com.example.administrator.zhongyichou.net.core.HttpLoader;
import com.example.administrator.zhongyichou.net.protocol.GsonBaseProtocol;
import com.example.administrator.zhongyichou.view.HeaderView;
import com.example.administrator.zhongyichou.view.MyExpandableListView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by lichenyu on 2017/11/21.
 * 描述：百万互助
 */

public class MillionsHelpActivity extends BaseActivity {
    @BindView(R.id.headerview)
    HeaderView headerview;
    @BindView(R.id.listview)
    MyExpandableListView listview;
    @BindView(R.id.btn_next)
    Button btnNext;
    @BindView(R.id.txt_desc)
    TextView txtDesc;
    @BindView(R.id.ll_update_condition)
    LinearLayout llUpdateCondition;
    @BindView(R.id.ll_assistance_scope)
    LinearLayout llAssistanceScope;
    @BindView(R.id.ll_update_price_cost)
    LinearLayout llUpdatePriceCost;
    @BindView(R.id.ll_highest)
    LinearLayout llHighest;
    @BindView(R.id.ll_year)
    LinearLayout llYear;
    @BindView(R.id.ll_average)
    LinearLayout llAverage;
    @BindView(R.id.ll_continue)
    LinearLayout llContinue;
    @BindView(R.id.ll_prompt)
    LinearLayout llPrompt;
    private MillionsHelpExpandableAdapter adapter;

    @Override
    protected void init() {
        ButterKnife.bind(this);
        initHead();
        adapter = new MillionsHelpExpandableAdapter(this);
        listview.setAdapter(adapter);
        //去掉箭头
        listview.setGroupIndicator(null);
    }

    @Override
    protected void responseData(GsonBaseProtocol mGsonBaseProtocal) {

    }

    @Override
    protected HttpLoader initHttpLoader() {
        return null;
    }

    @Override
    protected int initContentView() {
        return R.layout.millions_help_activity;
    }

    @Override
    public boolean onEventBus(BaseEventBean baseEventBean) {

        return false;
    }

    private void initHead() {
        headerview.setTitle("百万终身大病互助行动");
        headerview.bindOnclickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                switch (v.getId()) {
                    case HeaderView.LEFT:
                        finish();
                        break;
                }
            }
        });
    }

    @OnClick({R.id.btn_next, R.id.txt_desc, R.id.ll_update_condition, R.id.ll_assistance_scope, R.id.ll_update_price_cost, R.id.ll_highest, R.id.ll_year, R.id.ll_average, R.id.ll_continue, R.id.ll_prompt})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn_next:
                Intent intent = new Intent(this, MillionsJoinsActivity.class);
                startActivity(intent);
                break;
            case R.id.txt_desc://描述
                startActivity(R.string.millions_des);
                break;
            case R.id.ll_update_condition://升级条件
                startActivity(R.string.millions_update_condition);
                break;
            case R.id.ll_assistance_scope://获助范围
                startActivity(R.string.millions_assistance_scope);
                break;
            case R.id.ll_update_price_cost://升级费用
                startActivity(R.string.millions_update_price_cost);
                break;
            case R.id.ll_highest://最高获助
                startActivity(R.string.millions_highest);
                break;
            case R.id.ll_year://年费要求
                startActivity(R.string.millions_year);
                break;
            case R.id.ll_average://均摊规则
                startActivity(R.string.millions_average);
                break;
            case R.id.ll_continue://延续条件
                startActivity(R.string.millions_continue);
                break;
            case R.id.ll_prompt://特别提示
                startActivity(R.string.millions_prompt);
                break;
            case R.id.txt_phone:
                CallPhone.call(this, getString(R.string.phone));
                break;
        }
    }

    private void startActivity(int id) {
        Intent intent = new Intent(this, DetailsActivity.class);
        intent.putExtra("resource", id);
        startActivity(intent);
    }
}
